from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_experimental_option("detach", True)
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument('--headless')

url = "https://www.hzhr.com/web/login.html?type=person"
d = Chrome("C:/Users/chakcy/Desktop/ZPReptile/chromedriver/120.0.6099.217/chromedriver-win64/chromedriver.exe", options=options)
d.maximize_window()
d.implicitly_wait(10)
d.get(url)
ele_button = d.find_element(By.CSS_SELECTOR, '[id*="sliderVerify"] > div.slider-btn.layui-icon.layui-icon-next')
print('滑块按钮的宽：', ele_button.size['width'])
print('滑块按钮的高：', ele_button.size['height'])
ele = d.find_element(By.CSS_SELECTOR, '[id*="sliderVerify"]')
print('滑块区域的宽：', ele.size['width'])
print('滑块区域的高：', ele.size['height'])
chains = ActionChains(d)
chains.drag_and_drop_by_offset(ele_button, ele.size['width'] - ele_button.size['width'], 0)
chains.perform()

# import urllib.parse
 
# # 要编码的URL
# # url = "https://www.example.com/search?q=中文"
# url = "https://www.ajrczp.com/zhaopin/?key="
 
# # 进行URL编码
# encoded_url = urllib.parse.quote("普工")
# print("Encoded URL:", url+encoded_url)